﻿using System.Linq;
using System.Web.Mvc;
using VOD.Models;
using VOD.ViewModels;

namespace VOD.Controllers
{
    public class TVController : Controller
    {
        readonly VODEntities _db = new VODEntities();
        //
        // GET: /TV/
        public ActionResult Index()
        {
            return View();
        }

        // 电视频道首页的电影导航条
        public ActionResult AreaList()
        {
            var areas = from v in _db.v_Videos
                        where v.CategoryID == 3 && v.AreaName != null
                        group v by v.AreaName into g
                        select new AreaList
                        {
                            Name = g.Key
                        };
            ViewBag.CategoryID = 3;
            return View(areas);
        }

        // 年份列表
        public ActionResult YearList()
        {
            var years = from v in _db.v_Videos
                        where v.ShowYear != null && v.CategoryID==3
                        group v by v.ShowYear into g
                        select new ShowYear
                        {
                            Year = g.Key
                        };
            ViewBag.CategoryID = 3;
            return View(years);
        }

        protected override void Dispose(bool disposing)
        {
            _db.Dispose();
            base.Dispose(disposing);
        }
    }
}
